#!/bin/bash
# set -x
KAFKA_HOME=/home/k2data/kafka_2.10-0.8.2.2

while true; do
        # for raw-binary input
        raw_processed_offset_total=0
        raw_latest_offset_total=0
        time=$(date +%s)
        for i in $(cat raw_offsets)
        do
          raw_processed_offset=$(echo "get /zk_test/dataplatform/storm/Fixed-format-kafka-spout/$i" | $KAFKA_HOME/bin/zookeeper-shell.sh kmxnode3,kmxnode4,kmxnode6 2>/dev/null | tail -n 1 | jq '.offset')
.offset')
          raw_processed_offset_total=$(expr $raw_processed_offset_total + $raw_processed_offset)
        done
        for h in $($KAFKA_HOME/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 192.168.1.88:19092,192.168.1.89:19092 --time -1 --topic defaultUser-defaultSpace-raw | awk -F [:] '{print $3}')
        do
          raw_latest_offset_total=$(expr $raw_latest_offset_total + $h)
        done
        echo "put sdlg.kafka.raw.offset.processed.total $time $raw_processed_offset_total host=$(hostname -s)"
        echo "put sdlg.kafka.raw.offset.latest.total $time $raw_latest_offset_total host=$(hostname -s)"
        sleep 60
done #| nc 211.154.7.134 4242



